using System;
using DanielSig.Geometry;
using UnityEngine;

namespace DanielSig.UnityExtensions
{
	public static class XCarving
	{
		public static Carving[] RemoveSymmetrical(this Carving[] carvings)
		{
			return RemoveSymmetrical(carvings, 0F);
		}
		public static Carving[] RemoveSymmetrical(this Carving[] carvings, float threshold)
		{
			Carving[] newCarvings = new Carving[carvings.Length];
			int c = 0;
			for(int i = 0; i < carvings.Length; i++)
			{
				Carving current = carvings[i];
				bool addcurrent = true;
				for(int j = i; j < carvings.Length; j++)
				{
					if(current.Symmetrical(carvings[j], threshold))
					{
						addcurrent = false;
						break;
					}
				}
				if(addcurrent)
				{
					newCarvings[c++] = current;
				}
			
			}
			Array.Resize<Carving>(ref newCarvings, c);
			return newCarvings;
		}
	}
}

